<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%@ include file="/common/import.jsp" %>
<script type="text/javascript" src="${ctx}/js/date.js"></script> 
<script>
  var thsTitle = "单标的";
  var currentPage = 1;
  var objName="item";
  var currentObjId = "";
</script>
<title>竞价标的-${sysName }</title>
</head>
<body class="home-template"  style="background:url('') no-repeat center top">
<!-- 正文开始 -->
<table  class="info" cellspacing="1" cellpadding="0">
	<tr >
		<th>单标的：指的是每个标的的竞买人不同，每个标的的规则等都单独设置。</th>
	</tr>
	
</table>
<br>
<div id="main">

<div title="新增标的">
	<form id="addItemForm">
	<input type="hidden" name="sessionId"  value="0"/>
	<input type="hidden" name="sessionType"  value="3"/>
	<input type="hidden" name="sessionName"  value="--"/>
	<input type="hidden" name="orgEname"  value="${loginUser.orgEname}"/>
	<input type="hidden" name="orgCname"  value="${loginUser.orgCname}"/>
	<input type="hidden" name="itemStatus"  value="0"/>
	<input type="hidden" name="incrementGroup"  value=""/>
	<input type="hidden" name="direction" id="direction" value="T">
	<input type="hidden" name="groupId"  value="0"/>
	<input type="hidden" name="groupName"  value="--"/>
	
	<table class="info" cellspacing="1" cellpadding="0"/>
		<tr>
			<th width="20%">标的名称：</th>
			<td><input type="text" name="itemName"  value="" size="80" class="easyui-validatebox validatebox-text" 
			validtype="length[1,166]"	required="true"  missingMessage="请输入标的名称"  maxlength="166"
				invalidMessage="最多可输入166中文字符"  title="标的名称最多可输入166中文字符" /> </td>
		</tr>
		<tr>
			<th>特别说明：</th>
			<td><input type="text" name="spare1"  value="" size="80" maxlength="40" class="easyui-validatebox validatebox-text" 
			validtype="length[1,40]" missingMessage="请输入标的特别说明"  
				invalidMessage="最多可输入40中文字符"  title="标的特别说明最多可输入40中文字符" /> </td>
		</tr>
	<tr>
		<th>标的类型：</th>
		<td><input type="text" name="itemType" id="itemType" value="" size="80"/> 
		</td>
	</tr>
	<tr>
		<th>是否动态报价：<font color="red">*</font></th>
		<td>
			<input type="radio" name="ifBidDyn"  value="F" onclick="setIfBidDynCtr('F')" checked/>网络竞价 
			<input type="radio" name="ifBidDyn"  value="T" onclick="setIfBidDynCtr('T')"/>动态报价 &nbsp;&nbsp;
			
		</td>
	</tr>
		<tr>
			<th>竞价方式：<font color="red">*</font></th>
			<td><input type="text" name="bidMode" id="bidMode" /></td>
		</tr>
		<tr>
		<th>保证金：</th>
		<td>
			<input type="text" name="bailPrice" id="bailPrice" value="0" maxlength="20"  class="easyui-validatebox validatebox-text" 
			validtype="number" required="true"  missingMessage="请输入标的的保证金金额"	  invalidMessage="必须为非负的数字"  title="保证金" />
		</td>
		</tr>
		<tr>
			<th>货币单位/币种：</th>
			<td>
				<select name="priceUnit" ><option value="元">元</option><option value="万元">万元</option></select>
				<input name="currency" id="currency" value="" size="10"/>
			</td>
		</tr>
		<tr>
			<th>起始价格：</th>
			<td>
				<input type="text" name="firstValuePre" id="firstValuePre" value="" size="18" onchange="changePrice();" onblur="changeDecimal('firstValuePre');" class="easyui-validatebox validatebox-text" 
			validtype="number"	required="true"  missingMessage="请输入起始价格"  invalidMessage="必须为非负的数字"  title="请输入起始价格" /> 
				<select name="decimalCount" id="decimalCount"><option value="0">0位</option><option value="1">1位</option><option value="2" selected>2位</option><option value="3">3位</option><option value="4">4位</option><option value="5">5位</option><option value="6">6位</option></select><font color="red">(保留小数位)</font>
			</td>
		</tr>
		<tr>
			<th id="incrementValueText">加价幅度：</th>
			<td><input type="text" name="incrementValue" id="incrementValue"  value="" size="18" onchange="changePrice();" onblur="changeDecimal('incrementValue');"  class="easyui-validatebox validatebox-text" 
			validtype="number"	required="true"  missingMessage="请输入加价幅度"  invalidMessage="必须为非负的数字"  title="请输入加价幅度" /> </td>
		</tr>
		<tr id="allowFirstValueTr">
			<th>是否允许报起始价：</th>
			<td>
				<input type="radio" name="allowFirstValue" value="T" checked="checked" >是，从起始价<font id="fv1"></font>开始报价，
				<input type="radio" name="allowFirstValue" value="F">否，从起始价之上一个加价幅度<font id="fv2"></font>开始报价
			</td>
		</tr>		

		<tr id="openTimeTr">
			<th>竞价开始时间：</th>
			<td><input type="hidden" name="openTimePre" id="openTimePre" value="" size="18"/> 
			    <span id="openTimePre_dt">
				    <select class="myDate" size=1 id=openTimePre_y></select>年
					<select class="myDate" size=1 id=openTimePre_m></select>月
					<select class="myDate" size=1 id=openTimePre_d></select>日
					<select class="myTime" size=1 id=openTimePre_hh></select>时
					<select class="myTime" size=1 id=openTimePre_mm></select>分
					<select class="myTime" size=1 id=openTimePre_ss></select>秒
				</span>
				<a id="defineTxt" onclick="notDefine()">待定: 以后再设定竞价开始时间和结束时间</a>
			</td>
		</tr>
		<tr id="firstBidTimeTr">
			<th id="firstBidTimeTxt">限时开始时间：</th>
			<td><input type="hidden" name="firstBidTimePre"  id="firstBidTimePre" value="" size="18"/> 
				<div id="firstBidTimePre_dt">	
					<select class="myDate" id=firstBidTimePre_y></select>年
					<select class="myDate" id=firstBidTimePre_m></select>月
					<select class="myDate" id=firstBidTimePre_d></select>日
					<select class="myTime" id=firstBidTimePre_hh></select>时
					<select class="myTime" id=firstBidTimePre_mm></select>分
					<select class="myTime" id=firstBidTimePre_ss></select>秒
				</div>
			</td>
		</tr>
		<tr id="litmitTimeTr">
			<th id="litmitTimeText">限时报价周期：</th>
			<td><input type="text" name="limitTime" id="limitTime"  value="60" size="4"  class="easyui-validatebox validatebox-text" 
			validtype="number"	required="true"  missingMessage="请输入限时报价周期"  invalidMessage="必须为非负的数字"  title="限时报价周期"  onblur="if(this.value=='') {this.value='60';}"  />（秒） </td>
		</tr>
		<tr id="allowUpdateTimesTr">
			<th>允许修改报价次数：</th>
			<td><input type="text" name="allowUpdateTimes" id="allowUpdateTimes"  value="0" size="4" maxlength="1"  class="easyui-validatebox validatebox-text" 
			validtype="number"	required="true"  missingMessage="请输入允许修改报价次数"  invalidMessage="必须为非负的数字"  title="允许修改报价次数"  onblur="if(this.value=='') {this.value='0';}"  />（次） </td>
		</tr>

		<tr>
			<th>报价服务器：<font color="red">*</font></th>
			<td><select  id="bjServerStr" name="bjServerStr" /></select></td>
		</tr>
		<tr>			
			<td colspan="2" style="text-align:center;">
				<a class="easyui-linkbutton" iconCls="icon-add" id="addItemButt" onclick="addItem('0');">保存</a>
				<a class="easyui-linkbutton" iconCls="icon-add" onclick="addItem('2');" id="itemAddAndPub" <c:if test="${bidSession.status != 2}"> style="display:none;" </c:if> >保存并发布</a>
			</td>
		</tr>
	</table>
	</form>	
</div>
<!-- tab3  -->
<div title="未开始的标的" style="padding:10px;" >
	<div class="searchForm"><form id="notBeginList_form">
		<input type="hidden" name="page"  value="1">
		<input type="hidden" name="rows"  value="5">
		<input type="hidden" name="sessionId"  value="0">
		<!-- 存在currentTimePre隐藏域时，不需要 itemStatus参数(底层已存在)，否则查询条件会发生冲突 -->
		<input type="hidden" name="currentTimePre"  value="">
		标的名称：<input type="text" name="itemName"  value="" /> 
		<a class="easyui-linkbutton"  iconCls="icon-search" onclick="notBeginListSearch();">查询</a>
		<a class="easyui-linkbutton"  iconCls="icon-search" onclick="clearFormById('notBeginList_form');">清空</a>
	</form></div>
	<table id="notBeginList_table" class="info" cellspacing="1" cellpadding="0" >
		<tr class='active' id="title2" >
			<th width='20%'>标的名称</th>
			<th width='10%'>竞价方式</th>
			<th width='10%'>起始价格</th>
			<th width='15%'>竞价开始时间</th>	
			<th width='15%'>限时开始时间</th>	
			<th width='5%'>发布状态</th>
			<th width='30%' class='th_center'>操作</th>
		</tr>
	</table>
	<div id="notBeginList_page" class="page"></div>
	<script type="text/template" id="notBeginList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr id=item_<?=rows[i].itemId?>>
			<td  title=<?=rows[i].itemName?>><a class="mybutton"  onclick="goItem('<?=rows[i].itemId?>');"><?=strUtil.subStr(rows[i].itemName,18)?></a></td>
			<td><?=bidModeText(rows[i].bidMode)?></td>
			<td><?=rows[i].firstValuePre?>  <?=rows[i].priceUnit?></td>
			<td>
			<?if(rows[i].openTimePre=='2050-12-31 23:59:59'){?>
					待定 <a onclick="beginIt('<?=rows[i].itemId?>','<?=rows[i].itemName?>','<?=rows[i].ifBidDyn?>','<?=rows[i].bidMode?>')">确定竞价时间</a>
				<?}else{?>
					<?=rows[i].openTimePre?>
				<?}?>
			</td>
			<td><?=rows[i].firstBidTimePre?></td>
			<td><?=itemStatusTxt(rows[i].itemStatus)?></td>
			<td>
				<a class="mybutton"  onclick="goItem('<?=rows[i].itemId?>');">标的管理</a>  
				<?if(rows[i].itemStatus==0 || rows[i].itemStatus==1){?>
				     || <a class="mybutton"  onclick="pubItem('<?=rows[i].itemId?>');">发布</a>  
				     || <a class="mybutton"  onclick="del('<?=rows[i].itemId?>');">删除</a>
				<?}?>
					 || <a class="mybutton"  onclick="goPic('<?=rows[i].itemId?>','<?=rows[i].itemName?>');">图</a>
			</td>
		</tr>
   <?}?>  		
</script>
</div>
<!-- tab4  -->	
<div title="进行中的标的" style="padding:10px;">
	<div class="searchForm"><form id="runningList_form">
		<input type="hidden" name="page"  value="1">
		<input type="hidden" name="rows"  value="5">
		<input type="hidden" name="sessionId"  value="0">
		<input type="hidden" name="currentTimePre"  value="">
		标的名称：<input type="text" name="itemName"  value="" /> 
		<!-- 发布状态：<select name="itemStatus">
		<option value="">所有</option>
		<option value="B">自由报价期</option>
		<option value="C">限时报价期</option>
		</select> -->
		<a class="easyui-linkbutton"  iconCls="icon-search" onclick="runningListSearch();">查询</a>
		<a class="easyui-linkbutton"  iconCls="icon-search" onclick="clearFormById('runningList_form');">清空</a>
		<a onclick="dynLoad('ids')">加载动态数据</a>
	</form></div>
	<table id="runningList_table" class="info" cellspacing="1" cellpadding="0">
		<tr class='active' id="title2" >
			<th width='20%'>标的名称</th>
			<th width='10%'>竞价方式</th>
			<th width='8%'>起始价格</th>
			<th width='8%'>当前价格</th>	
			<th width='8%'>报价次数</th>
			<th width='10%'>最高报价人</th>
			<th width='10%'>竞价状态</th>		
			<th width='30%' class='th_center'>操作</th>
		</tr>
	</table>
	<div id="runningList_page" class="page"></div>
	<script type="text/template" id="runningList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
       
		<tr id=item_<?=rows[i].itemId?>>
			<td title=<?=rows[i].itemName?>><a class="mybutton"  onclick="goItem('<?=rows[i].itemId?>');"><?=strUtil.subStr(rows[i].itemName,18)?></a></td>
			<td><?=bidModeText(rows[i].bidMode)?></td>
			<td><?=rows[i].firstValue?>  <?=rows[i].priceUnit?></td>
			<td><?=rows[i].lastValue?>  <?=rows[i].priceUnit?></td>
			<td><?=rows[i].bidTimes?></td>
			<td><?if(rows[i].userName == null || rows[i].userName == "null" || rows[i].userName == ""){?>
				&nbsp;				
				<?}else{?>
				<?=rows[i].userName?>
				<?}?>
			</td>
			<td><?=itemStatusTxt(rows[i].itemStatus)?></td>
			<td>
				<a class="mybutton"  onclick="goItem('<?=rows[i].itemId?>');">标的管理</a>  
				|| <a class="mybutton"  onclick="viewRecord('<?=rows[i].itemId?>','<?=rows[i].bidMode?>');">报价记录</a>  
				|| <a class="mybutton"  onclick="compareCache('<?=rows[i].itemId?>');">比缓存</a>  
				<?if(rows[i].itemStatus==2){?>
				     || <a class="mybutton"  onclick="pauseItem('<?=rows[i].itemId?>');">暂停</a>
				<?}else if(rows[i].itemStatus==3){?>
				     || <a class="mybutton"  onclick="continueItem('<?=rows[i].itemId?>','<?=rows[i].firstBidTimePre?>');">继续</a>
					 || <a class="mybutton"  onclick="goPic('<?=rows[i].itemId?>','<?=rows[i].itemName?>');">图</a>
				<?}?>
				</td>
		</tr>
	<?}?>  		
	</script>
	
</div>
	
<!-- tab5  -->	
<div title="已结束的标的" style="padding:10px;">
	<div class="searchForm"><form id="endList_form">
		<input type="hidden" name="page"  value="1">
		<input type="hidden" name="rows"  value="5">
		<input type="hidden" name="sessionId"  value="0">
		标的名称：<input type="text" name="itemName"  value="" /> 
		<a class="easyui-linkbutton"  iconCls="icon-search" onclick="endListSearch();">查询</a>
		<a class="easyui-linkbutton"  iconCls="icon-search" onclick="clearFormById('endList_form');">清空</a>
	</form></div>
	<table id="endList_table" class="info" cellspacing="1" cellpadding="0">
		<tr class='active' id="title2" >
			<th width='15%'>标的名称</th>
			<th width='5%'>竞价方式</th>
			<th width='5%'>起始价格</th>
			<th width='5%'>报价次数</th>
			<th width='5%'>最高报价</th>
			<th width='5%'>最高报价人</th>
			<th width='5%'>溢价率</th>
			<th width='10%'>结束时间</th>		
			<th width='5%'>是否交割</th>	
			<th width='13%' class='th_center'>操作</th>
		</tr>
	</table>
	<div id="endList_page" class="page"></div>
	<script type="text/template" id="endList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr id=item_<?=rows[i].itemId?>>
			<td title=<?=rows[i].itemName?>><?=strUtil.subStr(rows[i].itemName,20)?></td>
			<td><?=bidModeText(rows[i].bidMode)?></td>
			<td><?=rows[i].firstValue?>  <?=rows[i].priceUnit?></td>
			<td><?=rows[i].bidTimes?></td>
			<td><?=rows[i].lastValue?>  <?=rows[i].priceUnit?></td>
			<td><?=strUtil.doNull(rows[i].userName)?></td>
			<td><?=rows[i].yjl?></td>
			<td><?=rows[i].closeTime?></td>
			<td>----</td>
			<td>
				<a class="mybutton"  onclick="restoreItem('<?=rows[i].itemId?>');">恢复</a> 
				<?if(rows[i].bidMode>0){?>				
					|| <a class="mybutton"  onclick="viewRecord('<?=rows[i].itemId?>','<?=rows[i].bidMode?>');">报价记录</a>
				<?}?>
			</td>
		</tr>
	<?}?>  		
	</script>	
</div>

	
</div>
<!-- 正文结束 -->
</body>
</html>


<!-- dialog1 查看报价记录 -->
<div id="jinjiaRecord_window" class="easyui-dialog" title="查看报价记录" modal="true" style="width:800px;height:400px" closed="true">
	<div class="searchForm"><form id="jinjiaRecord_form">
		<input type="hidden" name="page" value="1">
		<input type="hidden" name="rows" value="5">
		<input type="hidden" name="itemId" value="">
		报价人：<input type="text" name="userName"  value="" /> 
		<a class="easyui-linkbutton"  iconCls="icon-search" onclick="jinjiaRecordSearch();">查询</a>
	</form></div>
	<table id="jinjiaRecord_table" class="info" cellspacing="1" cellpadding="0">
		<tr class='active' id="title2" >
			<th width='5%'>报价序号</th>
			<th width='20%'>报价人</th>
			<th width='10%'>报价价格</th>	
			<th width='20%'>报价时间</th>
			<th width='15%'>报价人IP</th>
		</tr>
	</table>
	<div id="jinjiaRecord_page" class="page"></div>
	<script type="text/template" id="jinjiaRecord_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
			<td><?=rows.length-i?></td>
			<td><?=rows[i].userName?></td>
			<td><?=rows[i].bidValue?></td>
			<td><?=rows[i].bidTime?></td>
			<td><?=rows[i].userIp?></td>
		</tr>
	<?}?>  		
	</script>
</div>

<!-- dialog3 继续窗口 -->
<div id="continue_window" class="easyui-dialog" title="new" modal="true" style="width:600px;height:330px" closed="true">
	<form id="continueForm">
		<input type="hidden" name="itemId" id="continue_itemId">
		<table class="info" cellspacing="1" cellpadding="0">
			<tr>
			<th>限时开始时间：</th>
			<td><input type="hidden" name="firstBidTime" id="continueFirstBidTime"  /> 
				<select class="myDate" size=1 id=continueFirstBidTime_y></select>年
				<select class="myDate" size=1 id=continueFirstBidTime_m></select>月
				<select class="myDate" size=1 id=continueFirstBidTime_d></select>日
				<select class="myTime" size=1 id=continueFirstBidTime_hh></select>时
				<select class="myTime" size=1 id=continueFirstBidTime_mm></select>分
				<select class="myTime" size=1 id=continueFirstBidTime_ss></select>秒
			</td>
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">
				<a class="easyui-linkbutton" id="updateApplyButton" iconCls="icon-add" onclick="continueItemDo();">继续竞价</a>
				</td>
			</tr>			
		</table>
		
	</form>
</div>
<!-- dialog3 恢复窗口 -->
<div id="restore_window" class="easyui-dialog" title="new" modal="true" style="width:600px;height:330px" closed="true">
	<form id="restoreForm">
		<input type="hidden" name="itemId" id="restore_itemId">
		<table class="info" cellspacing="1" cellpadding="0">
			<tr>
			<th>竞价开始时间：</th>
			<td><input type="hidden" name="openTime" id="restoreOpenTime" /> 
				<select class="myDate" size=1 id=restoreOpenTime_y></select>年
				<select class="myDate" size=1 id=restoreOpenTime_m></select>月
				<select class="myDate" size=1 id=restoreOpenTime_d></select>日
				<select class="myTime" size=1 id=restoreOpenTime_hh></select>时
				<select class="myTime" size=1 id=restoreOpenTime_mm></select>分
				<select class="myTime" size=1 id=restoreOpenTime_ss></select>秒
			</td>
			</tr>
			<tr>
			<th>限时开始时间：</th>
			<td><input type="hidden" name="firstBidTime" id="restoreFirstBidTime"  /> 
				<select class="myDate" size=1 id="restoreFirstBidTime_y"></select>年
				<select class="myDate" size=1 id="restoreFirstBidTime_m"></select>月
				<select class="myDate" size=1 id="restoreFirstBidTime_d"></select>日
				<select class="myTime" size=1 id="restoreFirstBidTime_hh"></select>时
				<select class="myTime" size=1 id="restoreFirstBidTime_mm"></select>分
				<select class="myTime" size=1 id="restoreFirstBidTime_ss"></select>秒
			
			</td>
			</tr>
			<tr>
			<th>是否保留原来报价记录：</th>
			<td><input type="radio" name="record" value="T" checked="true"/>保留，
			<input type="radio" name="record" value="F" />不保留，
			</td>
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">
				<a class="easyui-linkbutton" id="updateApplyButton" iconCls="icon-add" onclick="restoreItemDo();">恢复</a>
				</td>
			</tr>			
		</table>
		
	</form>
</div>

<!-- dialog3 开始窗口 -->
<div id="begin_window" class="easyui-dialog" title="new" modal="true" style="width:600px;height:330px" closed="true">
	<form id="beginForm">
		<input type="hidden" name="itemId" id="begin_itemId">
		<input type="hidden"  id="begin_bidMode">
		
		<table class="info" cellspacing="1" cellpadding="0">
			<tr>
			<th>竞价开始时间</th>
			<td><input type="hidden" name="OpenTimePre" id="beginOpenTime"  /> 
				<select class="myDate" size=1 id=beginOpenTime_y></select>年
				<select class="myDate" size=1 id=beginOpenTime_m></select>月
				<select class="myDate" size=1 id=beginOpenTime_d></select>日
				<select class="myTime" size=1 id=beginOpenTime_hh></select>时
				<select class="myTime" size=1 id=beginOpenTime_mm></select>分
				<select class="myTime" size=1 id=beginOpenTime_ss></select>秒
			</td>
			</tr>
			<tr id="beginFirstBidTimeTr">
			<th id="beginFirstBidTimeTxt">限时开始时间：</th>
			<td><input type="hidden" name="firstBidTimePre" id="beginFirstBidTime"  /> 
				<select class="myDate" size=1 id=beginFirstBidTime_y></select>年
				<select class="myDate" size=1 id=beginFirstBidTime_m></select>月
				<select class="myDate" size=1 id=beginFirstBidTime_d></select>日
				<select class="myTime" size=1 id=beginFirstBidTime_hh></select>时
				<select class="myTime" size=1 id=beginFirstBidTime_mm></select>分
				<select class="myTime" size=1 id=beginFirstBidTime_ss></select>秒
			</td>
			</tr>
			<tr id="beginLimitTimeTr">
				<th id="beginLimitTimeTxt">限时报价周期：</th>
				<td><input type="text" size="3" id="beginLimitTime" name="limitTime" value="60">(秒)</td>
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">
				<a class="easyui-linkbutton" id="beginButton" iconCls="icon-add" onclick="beginDo();">开始竞价</a>
				</td>
			</tr>			
		</table>
	</form>
</div>

<!-- dialog3 比较窗口 -->
<div id="new-window" class="easyui-dialog" title="new" modal="true" style="width:900px;height:530px" closed="true">
<iframe id="new-window-url" style="border:0px;width:880px;height:460px;">
</iframe>
</div>
<script>
var bidMode= "";
//未开始的标的查询
function setIfBidDynCtr(flag){
	setMyTime("openTimePre");
	var optime = $("#openTimePre").val();
	var nextd="";
	if(flag=="T"){
		 nextd = getNextTime(optime,5*24*3600);
		 initMyTime('firstBidTimePre',nextd);
	}else{
		 nextd = getNextTime(optime,3600);
		 initMyTime('firstBidTimePre',nextd);
	}
}

function notBeginListSearch(){
	$("#notBeginList_form").find("input[name='currentTimePre']").val(getNowFormatDate());
	searchSubmit("item","notBeginList");
}
//进行中的标的查询
function runningListSearch(){
    $("#runningList_form").find("input[name='currentTimePre']").val(getNowFormatDate());
	searchSubmit("price","runningList");
}
//已结束的标的查询
function endListSearch(){
	searchSubmit("itemHistory","endList");
}
//竞买人查询
function jinjiaRecordSearch(bidMode){
	if(bidMode == '1' || bidMode == '2' || bidMode == '7'){
	   searchSubmit("jingjia","jinjiaRecord");
	}else if(bidMode == '3' || bidMode == '4' || bidMode == '5' || bidMode == '6'){
	   searchSubmit("baojia","jinjiaRecord");
	}
}

function changeMode(bmode){
	//alert(bmode);
	bidMode = bmode;
	if(bidMode=="7"){
		$("#allowFirstValueTr").hide();
		$("#firstBidTimeTr").hide();
		$("#allowUpdateTimes").val("0");
		$("#allowUpdateTimesTr").hide();
		$("#limitTime").val('60');
		$("#litmitTimeTr").show();
		$("#litmitTimeText").html("降价周期");
		$("#incrementValueText").html("降价幅度");
	}else if(bidMode=="3" || bidMode=="4" || bidMode=="5" || bidMode=="6"){
		$("#allowFirstValueTr").show();
		$("#firstBidTimeTr").show();
		$("#allowUpdateTimes").val("0");
		$("#allowUpdateTimesTr").show();
		$("#limitTime").val('0');
		$("#litmitTimeTr").hide();
		$("#firstBidTimeTxt").html("报价结束时间");
		if(bidMode=="4" || bidMode=="6"){
			$("#incrementValueText").html("降价幅度");
		}else{
			$("#incrementValueText").html("加价幅度");
		}
	}else if(bidMode=="1" || bidMode=="2"){
		$("#allowFirstValueTr").show();
		$("#firstBidTimeTr").show();
		$("#allowUpdateTimes").val("0");
		$("#allowUpdateTimesTr").hide();
		$("#limitTime").val('60');
		$("#litmitTimeTr").show();
		$("#firstBidTimeTxt").html("限时开始时间");
		$("#litmitTimeText").html("限时报价周期");
		if(bidMode=="2"){
			$("#incrementValueText").html("降价幅度");
		}else{
			$("#incrementValueText").html("加价幅度");
		}
	}
	
}

var manuBegin="F";
function notDefine(){
	if(manuBegin=="F"){
		manuBegin="T";
		$("#openTimePre_dt").hide();
		$("#firstBidTimePre_dt").hide();
		$("#defineTxt").html('现在设定竞价开始时间和结束时间');
	}else{
		manuBegin="F";
		$("#openTimePre_dt").show();
		$("#firstBidTimePre_dt").show();
		$("#defineTxt").html('待定: 以后再设定竞价开始时间和结束时间');
	}
	
}

//新增标的记录
function addItem(statusValue){
    $("#addItemButt").attr("disabled","disabled");
    $("#itemAddAndPub").attr("disabled","disabled");
	var addItemformName = "addItemForm";
	var fvalue = $('#'+addItemformName).find("input[name='firstValuePre']").val();
	$('#'+addItemformName).find("input[name='itemStatus']").val(statusValue);
	$('#'+addItemformName).find("input[name='incrementGroup']").val(fvalue);
	if(bidMode==""){
		bidMode="1";
	}
	if(bidMode=="3" || bidMode=="4" || bidMode=="5"|| bidMode=="6"){
		$("#limitTime").val('0');
	}
	if(bidMode=="1" || bidMode=="3" || bidMode=="5" || bidMode=="7"){
    	$('#addItemForm').find("input[name='direction']").val("T");
    }else{
    	$('#addItemForm').find("input[name='direction']").val("F");
    }
	if(manuBegin=="F"){
		setMyTime('openTimePre');//把竞价开始时间放到隐藏域中
		setMyTime('firstBidTimePre');
	}else{
		$("#openTimePre").val("2050-12-31 23:59:59");
		$("#firstBidTimePre").val("2050-12-31 23:59:59");
	}
	
	if(bidMode=="7"){
		var ot = $("#openTimePre").val();
		$("#firstBidTimePre").val(ot);
	}
	var otp = $("#openTimePre").val();
	var fbtp = $("#firstBidTimePre").val();
	if(fbtp < otp){
		alert("限时开始时间不能早于竞价开始时间");
		return ;
	}
	
	if(bidMode == '1' || bidMode == '2' || bidMode == '7'){
		var limitTime = $('#limitTime').val();
		if(limitTime == 0){
			alert("限时报价周期值不能为0！");
			return;
		}
	}
	addSubmit("item",addItemformName);	
}

//新增后回调方法
function addCallBack(flag,msg,objName){
	if(flag=="T"){
		alert("保存成功！");
		if(objName=="content"){
			$("#"+noticeOrRule+"_form").find("input[name='infoId']").val(msg);
		}else if(objName=="para"){
			$("#paraForm").find("input[name='printId']").val(msg);
		}else if(objName=="item"){
			//clearFormById('addItemForm');
			alert("操作成功！");
			$("#addItemButt").removeAttr("disabled","disabled");
			$("#itemAddAndPub").removeAttr("disabled","disabled");
		}else if(objName=="apply"){
			clearFormById('addApplyForm');
			$("#addApply_window").dialog('close');
			if(itemApplyId && itemApplyId!="0"){
				applyItemListSearch();
			}else{
				applyListSearch();
			}
		}else{
		}
	}else{
		alert("提交失败！"+msg);
	}
	
}


//删除
function del(objId){
	if(confirm("确定要删除吗？")){
		delSubmit(objName,objId);
	}
}

//删除后回调方法
function delCallBack(flag,objName){
	if(flag=="T"){
		if(objName=="item"){
		  var pp = $('#main').tabs('getSelected');   
		  searchByTabtitle(pp.panel('options').title);//根据当前选项卡的title，执行相应search方法
		};
	}else{
		alert("删除失败！");
	}
}

//reload当前tab列表数据
function currentTabListSearch(){
  var pp = $('#main').tabs('getSelected');   
  searchByTabtitle(pp.panel('options').title);//根据当前选项卡的title，执行相应search方法
}

//根据当前选项卡的title，执行相应search方法
function searchByTabtitle(title){
   if("未开始的标的"==title){
		notBeginListSearch();
	}else if("进行中的标的"==title){
		runningListSearch();
	}else if("已结束的标的"==title){
		endListSearch();
	}
}

function beginIt(itemId,itemName,ifBidDyn,bidMode){
	$("#begin_itemId").val(itemId);
	$("#begin_bidMode").val(bidMode);
	createMyTimeOption('beginOpenTime');
	createMyTimeOption('beginFirstBidTime');
	var ss;
	if(ifBidDyn=="T"){
		ss = 5*24*60*60;
	}else{
		ss = 60*60;
	}
	var nowd = getNow();
	initMyTime('beginOpenTime',nowd);
	//alert(bidMode);
	if(bidMode=="7"){
		$("#beginFirstBidTimeTr").hide();
		$("#beginLimitTime").val('60');
		$("#beginLimitTimeTr").show();
		$("#beginLimitTimeTxt").html("降价周期");
	}else{
		var nextd =getNextTime(nowd,ss);
		initMyTime('beginFirstBidTime',nextd);
		$("#beginFirstBidTimeTr").show();
		if(bidMode=="1"||bidMode=="2"){
			$("#beginFirstBidTimeTxt").html("限时开始时间");
			$("#beginLimitTime").val('60');
			$("#beginLimitTimeTr").show();
			$("#beginLimitTimeTxt").html("限时竞价周期");
		}else{
			$("#beginFirstBidTimeTxt").html("竞价结束时间");
			$("#beginLimitTime").val('0');
			$("#beginLimitTimeTr").hide();
		}
		
	}
	
	$("#begin_window").dialog({title:"设置【"+itemName+"】竞价开始时间"});
	$("#begin_window").dialog('open');
}

function beginDo(){
	var itemId = $("#begin_itemId").val();
	var bidMode = $("#begin_bidMode").val();
	if(bidMode=="7"){
		alert(7);
		var op=$("#beginOpenTime").val();
		$("#beginFirstBidTime").val(op);
	}
	editSubmit("item",itemId,"beginForm");
}
function editCallBack(flag,objName){
	if(flag=="T"){
		 $("#begin_window").dialog('close');
		  alert("设置成功");
		  notBeginListSearch();
	}else{
		alert("操作失败！");
	}
}

function pubItem(itemId){
	if(confirm("发布后网站上就可以看到该标的了，确定要发布吗？")){
		//alert(itemId);
		pubItemSubmit(itemId);
		notBeginListSearch();
	}	
}
function pubItemBack(flag,msg){
	if(flag=="T"){
		notBeginListSearch();
	}else{
		alert("发布失败，"+msg);
	}
}
//
function viewRecord(itemId,bidMode){
	$("#jinjiaRecord_form").find("input[name='itemId']").val(itemId);
	jinjiaRecordSearch(bidMode);
	$("#jinjiaRecord_window").dialog("open");
}

//比缓存
function compareCache(itemId){
	//var ourl="${ctx}/sendPage/admin/viewJsp/compareItem?itemId="+itemId;
	//alert(ourl);
	var ourl = ctx+spaceDomain + "item/compareItem?itemId="+itemId;
	$("#new-window-url").attr('src',ourl);
	$("#new-window").dialog({title:"比较标的的数据库和缓存内容"});
	$("#new-window").dialog('open');
}

function goItem(itemId){
	//alert(itemId);
	window.location.href= ctx+spaceDomain+objName+"/view?itemId="+itemId+"&toType=portal";
}

function pauseItem(itemId){
	if(confirm("暂停后网站上不可以看到了，确定要暂停吗？")){
		pauseItemSubmit(itemId);
	}
}
function pauseItemBack(flag,msg){
	if(flag=="T"){
		alert("暂停操作完成");
		//notBeginListSearch();
		runningListSearch();
	}else{
		alert("暂停操作失败，"+msg);
	}
}

function restoreItem(itemId){
	$("#restore_itemId").val(itemId);
	var nowd = getNowFormatDate();
	$("#restore_window").dialog('open');
	initMyTime('restoreFirstBidTime',nowd);
	initMyTime('restoreOpenTime',nowd);
	
}
function restoreItemDo(){
	if(confirm("此操作请慎重使用，确定要恢复吗？")){
		setMyTime('restoreFirstBidTime');
		restoreItemSubmit('restoreForm');
	}	
}

function restoreItemBack(flag,msg){
	if(flag=="T"){
		alert("已恢复");
		endListSearch();
	}else{
		alert("恢复失败，"+msg);
	}
}
//暂停后的继续竞价
function continueItem(itemId,fbTime){
	$("#continue_itemId").val(itemId);
	var nowd = getNowFormatDate();
	initMyTime('continueFirstBidTime',fbTime);
	$("#continue_window").dialog('open');
}
function continueItemDo(){
	if(confirm("继续后网站上就可以看到了，确定要继续吗？")){
		setMyTime('continueFirstBidTime');
		continueItemSubmit('continueForm');
	}
}
function continueItemBack(flag,msg){
	if(flag=="T"){
		alert("继续操作完成");
		$("#continue_window").dialog('close');
		runningListSearch();
	}else{
		alert("继续操作失败，"+msg);
	}
}

//初始化加载
$(function(){
	$("#main").tabs({
		onSelect:function(title){
			if("未开始的标的"==title){
				notBeginListSearch();
			}else if("进行中的标的"==title){
				runningListSearch();
			}else if("已结束的标的"==title){
				endListSearch();
			}
		}
	});
	//竞价方式
	loadDiceOneStep('bidMode','bidMode',0,'${ctx}','changeMode');
	$("#allowUpdateTimesTr").hide();
	//报价服务器
	//jsonDataSelect("bjServerStr","server","");
	jsonDataSelectAjax("bjServerStr","server");
	jsonDataSelect("itemType","variety","","","");//初始化标的类型combobox 

	 createMyTimeOption('openTimePre');
	 createMyTimeOption('firstBidTimePre');
	 createMyTimeOption('continueFirstBidTime');
	 var nowd = getNow();
	 var nextd = getNextTime(nowd,3600);
	 initMyTime('openTimePre',nowd);
	 initMyTime('firstBidTimePre',nextd);
	 createMyTimeOption('restoreOpenTime');
     createMyTimeOption('restoreFirstBidTime'); 
     loadDiceOneStep_("currency","currency","0",'${ctx}','CNY');
});

function loadDiceOneStep(firstId,cateEname,fatherValue,ctx,callBack) {
	$('#'+firstId).combobox({
		url : ctx+'/dict.do?cateEname='+cateEname+'&fatherValue='+fatherValue,
		value:'1',
		valueField : 'id',
		editable : false,
		textField : 'text',
		onSelect:function(rec){
			if(callBack != null && callBack != ""){
				changeMode(rec.id);
			}
		}
	});
}

function loadDiceOneStep_(firstId,cateEname,fatherValue,ctx,value,callBack) {
		$('#'+firstId).combobox({
			url : ctx+'/dict.do?cateEname='+cateEname+'&fatherValue='+fatherValue,
			value:value,
			valueField : 'id',
			editable : false,
			textField : 'text',
			onSelect:function(rec){
				if(callBack != null && callBack != ""){
					dictOneCallBack(rec,firstId,cateEname);
				}
			}
		});
}

//标的图
function goPic(itemId,itemName){
    $("new-window-url").html('');
    var ourl = "${atta_server}/attachment/store/list.action?objId="+itemId+"&objType=${atta_objType}";
	//alert(ourl);
	$("#new-window-url").attr('src',ourl);
	$("#new-window").dialog({title:"【"+itemName+"】图片管理"});
	$("#new-window").dialog('open');
}
//小数位数变化(四舍五入)
function changeDecimal(id){
	var decimalCount = $("#decimalCount").val();
	var val = $('#'+id).val();	
	if(!isNaN(val)){
		 var result = Math.round(val * Math.pow(10, decimalCount)) / Math.pow(10, decimalCount);
		 $('#'+id).val(result);
	}
}
</script>